<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
<h:outputStylesheet library="css" name="table-style.css" />
</h:head>

<h:body>


	<h1>JSF SPRING HIBERNATE</h1>

<h:form>
	<h:dataTable value="#{studentBean.getStudentList()}" var="s"
		styleClass="order-table" headerClass="order-table-header"
		rowClasses="order-table-odd-row,order-table-even-row">

		<h:column>
			<f:facet name="header">
    				Student ID
    			</f:facet>
    				#{s.id}
    		</h:column>

		<h:column>
			<f:facet name="header">
    				First Name
				</f:facet>
    				#{s.fname}
    		</h:column>

		<h:column>
			<f:facet name="header">
    				Last Name
				</f:facet>
    				#{s.lname}
    		</h:column>

		<h:column>
			<f:facet name="header">
    				Email
				</f:facet>
    				#{s.email}
    		</h:column>

		<h:column>
			<f:facet name="header">
    				Phone
				</f:facet>
    				#{s.phone}
    		</h:column>
    		
    		<h:column>
 
    			<f:facet name="header">Action</f:facet>
 
    			<h:commandLink value="Delete" 
                                action="#{studentBean.deleteStudent(s)}" />
 
    		</h:column>

	</h:dataTable>
	</h:form>
	<h:form>

	<h2>Add New Student</h2>

		<h:panelGrid columns="3">
 
				First Name : 
				<h:inputText id="fname" value="#{studentBean.fname}" size="20"
				required="true" label="fname">
			</h:inputText>

			<h:message for="fname" style="color:red" />
 
				Last Name : 
				<h:inputText id="lname" value="#{studentBean.lname}" cols="20"
				rows="10" required="true" label="lname">
			</h:inputText>

			<h:message for="lname" style="color:red" />
			
			
				Email : 
				<h:inputText id="email" value="#{studentBean.email}" cols="20"
				rows="10" required="true" label="email">
			</h:inputText>

			<h:message for="email" style="color:red" />
			
				Phone : 
				<h:inputText id="phone" value="#{studentBean.phone}" cols="20"
				rows="10" required="true" label="phone">
			</h:inputText>

			<h:message for="phone" style="color:red" />
			

		</h:panelGrid>

		<h:commandButton value="Submit" action="#{studentBean.addStudent()}" />

	</h:form>
</h:body>

</html>